<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .content{
      margin-top: 50px;
      text-align: center;
    }
    .header{
      margin-bottom: 50px;
    }
    span{
      font-size: 30px;
    }
    .qs{
      font-size: 30px;
      display: inline-block;
    }
    .btn{
      
      margin-left:450px ;
    }
    .btn .start{
      width: 110px;
      height: 50px;
      display: inline-block;
     margin-right: 30px;
    }
    .end{
      width: 110px;
      height: 50px;
      display: inline-block;
    }
  </style>
</head>
<body>
  <div class="content">
  <div class="header">
    <span>名字是:</span>
    <div class="qs"></div>
  </div>
  <div class="btn">
    <button class="start">开始</button>
    <button class="end">结束</button>

  </div>
</div>
  <script>
    let arr = ['ikun','我'];
    let random = 0
    let n = 0
    let qs = document.querySelector('.qs')
    const start = document.querySelector('.start')
    const end = document.querySelector('.end')

    start.addEventListener('click',function(){
      
      n = setInterval(function(){
        random = Math.floor(Math.random() * arr.length)
        qs.innerHTML = arr[random]
      },100)
      if(arr.length === 1){
        start.disabled = true
        end.disabled = true
      }
    })
    end.addEventListener('click',function(){
      clearInterval(n)
      arr.splice(random,1)
      console.log(arr);
    })
  </script>
</body>
</html>